$(document).ready(function() {
	$("body").prepend('<div class="hide" id="resultMensage"><div class="background"></div><div class="notification"><a class="close" href="#">Fechar</a><em></em><span></span></div></div>');
	$("#resultMensage a.close").click(function(){closeMensage(0)});	
	$("body").prepend('<div class="hide" id="modalDelete"><h2>Deseja realmente excluir este item?</h2><br><div class="container_right"><a href="javascript:void(0);" id="confirm" onclick="" class="button box_circle"><span>Sim</span></a><a href="javascript:void(0);" onclick="$.modal.close();" class="button box_circle"><span>Não</span></a></div></div>');
});



function resultMensage(obj, closeModal){
	var objMsg = $("#resultMensage");

	$(objMsg).unbind();

	if(closeModal)
		$.modal.close();

	if(obj[0]){
		$(".notification span",objMsg).html(obj[1]);
		$(".notification em",objMsg).html('<img alt="" src="'+SITE+'files/images/icons/tick_circle.png">');
	}else{
		$(".notification span",objMsg).html(obj[1]);
		$(".notification em",objMsg).html('<img alt="" src="'+SITE+'files/images/icons/cross_circle.png">');
	}
	
	if($(objMsg).css("display") == "none")
		$(objMsg).slideDown('fast',function(){closeMensage(5000);});
}

function closeMensage(timer){
	var t = setTimeout(function(){
		if($("#resultMensage").css("display") == "block"){
			$("#resultMensage").slideUp('fast',function(){
				$(".notification",this).removeClass("confirm");
				$(".notification",this).removeClass("error");
			});
		}
	}, 
	timer);
}

function listOBJ(obj){
	var x,temp = "";

	for(x in obj)
		temp += x + " ";

	alert(temp);
}


var dadosHash;
	
function initHash(){
	var obj	  = document.location.hash.split('#');
	var x, temp;
	dadosHash = new Object();

	if(obj.length > 1){
		obj = obj[1].toString().split('&');

		for(x in obj){				
			temp = obj[x].toString().split('=');
			dadosHash[temp[0]] = temp[1];
		}			
	}
}

function addHash(name, value){
	var x, temp = "";
	initHash();
	
	if(name != ""){
		dadosHash[name] = value;

		for(x in dadosHash){
			if(temp != "")
				temp += '&';
			temp += x + "=" + dadosHash[x];
		}
	}

	document.location.hash = temp;
}

function getHash(name){
	try{
		if(dadosHash[name] != undefined)
			return dadosHash[name];
	}catch(e){}	

	return "";
}
